﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link href="~/Content/entrypareCSS.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="home-register">
        <span id="home-BiaoTi">Hello</span>
        <div id="home-numberFrame">
            <input type="text" id="nmuber" class="WenBenColor-B" />
        </div>
        <div>
            <span id="numberJingGao"></span>
        </div>
        <div id="home-pwdFrame">
            <input type="text" id="pwd" class="WenBenColor-B" />
        </div>
        <div>
            <span id="pwdJingGao"></span>
        </div>
        <div id="home-TiJiao">
            <input type="button" id="TiJiao" value="登 录" />
        </div>
		<div class="home-ZhuChe"><a href="~/MyHome/register">注 册</a></div>
    </div>
    <script src="~/Scripts/jquery-3.4.1.js"></script>
    <script src="~/Scripts/entryPageJS.js"></script>
    <script>
		$(function () {
			//背景
            $("body").css("background-image", "url('@ViewBag.backImage_entryPage')");
			//掩盖
			var YanGai = function () {
                pwd = $("#pwd").val();
                var b = "";
				var a = "@ViewBag.pwd";
				for (var i = 0; i < a.length; i++) {
                    b = b + "*";
                }
                $("#pwd").val(b);
			}
			//判断登录
			$("#TiJiao").click(function() {
				if ($("#numberJingGao").text() == "") {
					//判断是否为空
					if ($("#nmuber").val() == "UserNumber") {
						$("#numberJingGao").text("请输入账号");
						return;
					}
					if ($("#pwd").val() == "UserPassword") {
						$("#pwdJingGao").text("请输入密码");
						return;
					}
					//传输
					$.post("@Url.Action("register", "MyHome")", {
							number: $("#nmuber").val(),
							pwd: pwd
						},
						function(data) {
							console.log("已接收");
							if (data.State == 1) {
                                $("#pwdJingGao").text(data.Message)
							}
							if (data.State == 0) {
								console.log(data.Message);
								$("#pwd").val("");
								$("#home-register").animate({}, 2000, function() {
                                    location.href = data.skipPage;
								})
							}
						}
					)
				}
			})
			//密码框获得焦点出现阴影
			var pwd = "";
			$("#pwd").focus(function() {
				//提示消失
				if ($(this).val() == "UserPassword") {
					$(this).val("");
					$(this).addClass("WenBenColor-A");
					$(this).removeClass("WenBenColor-B");
				}
				//警告消失
				$("#pwdJingGao").text("");
				//阴影出现
				var shedu = 0;
				var numberTime = setInterval(function() {
					$("#pwd").css("box-shadow", "0px 0px " + shedu + "px 0px #FF6666");
					shedu = shedu + 1;
					if (shedu > 30) {
						clearInterval(numberTime);
					}
				}, 20);
				//显示密码
				$(this).val(pwd);
			}).blur(function() {
				//为空时提示出现
				if ($(this).val() == "") {
					$(this).val("UserPassword");
					$(this).toggleClass("WenBenColor-A WenBenColor-B");
				}
				//阴影消失
				var shedu = 30;
				var numberTime = setInterval(function() {
					$("#pwd").css("box-shadow", "0px 0px " + shedu + "px 0px #FF6666");
					shedu = shedu - 1;
					if (shedu < 0) {
						clearInterval(numberTime);
					}
				}, 20);
				//密码掩盖
				if ($(this).val() != "UserPassword") {
					YanGai();
				}
				//清空时同时清空字符串
				if($(this).val() == "UserPassword"){
					pwd = "";
				}
			})
			//账号框获得焦点出现阴影
			var numberHefa = true;
			$("#nmuber").focus(function() {
				//警告消失
				$("#numberJingGao").text("");
				//提示消失
				if ($("#nmuber").val() == "UserNumber") {
					$("#nmuber").val("");
					$(this).addClass("WenBenColor-A");
					$(this).removeClass("WenBenColor-B");
				}
				//警告消失
				$("#numberJingGao").text("");
				//阴影出现
				var shedu = 0;
				var numberTime = setInterval(function() {
					$("#nmuber").css("box-shadow", "0px 0px " + shedu + "px 0px #FF6666");
					shedu = shedu + 1;
					if (shedu == 30) {
						clearInterval(numberTime);
					}
				}, 20);
			}).blur(function() {
				//为空时提示出现
				if ($("#nmuber").val() == "") {
					$("#nmuber").val("UserNumber");
					$(this).toggleClass("WenBenColor-A WenBenColor-B");
				}
				//阴影消失
				var shedu = 30;
				var numberTime = setInterval(function() {
					$("#nmuber").css("box-shadow", "0px 0px " + shedu + "px 0px #FF6666");
					shedu = shedu - 1;
					if (shedu == 0) {
						clearInterval(numberTime);
					}
				}, 20);
				//判断账号合法性
				var number = $(this).val();
				if ((isNaN(number) == true && number != "UserNumber")) {
					$("#numberJingGao").text("账号类型不正确");
					numberHefa = false;
				} else {
					numberHefa = true;
				}
			})
			//读取上一次的账号密码
			$("#nmuber").val("@ViewBag.number");
			$("#pwd").val("@ViewBag.pwd");
			//进行掩盖
			if ($("#pwd").val() != "UserPassword") {
				YanGai();
			}
		})
    </script>
</body>

</html>

